﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Entities;
using BLL;
namespace Stationery.UC
{
    public partial class UC_UploadPriceReport_Update : System.Web.UI.UserControl
    {

        protected void Page_Load(object sender, EventArgs e)
        {
            LabelError.Visible = false;
        }

        protected void ASPxButtonSave_Click(object sender, EventArgs e)
        {
            //luu
            if (ASPxUploadControl1.HasFile)
            {
                string strFileName = Utils.price_report;
                if (ASPxUploadControl1.FileName.Contains(".xls") || ASPxUploadControl1.FileName.Contains(".doc") || ASPxUploadControl1.FileName.Contains(".docx"))
                {
                    strFileName = Server.MapPath("Files\\" + strFileName);
                    ASPxUploadControl1.SaveAs(strFileName, true);
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "message", "alert('Thành công');location.href = 'Admin.aspx?id=uploadprice';", true);
                }
                else
                {
                    LabelError.Visible = true;
                    LabelError.Text = "Loại File phải là .xls/ .doc/ .docx";
                }
            }
            else
            {
                LabelError.Visible = true;
                LabelError.Text = "Bạn chưa chọn File upload";
            }
        }
    }
}